package com.czjtxy.extraTerm.controller.noticemodule;

import com.czjtxy.extraTerm.entity.VO.TnoticeVO;
import com.czjtxy.extraTerm.server.NoticeService;
import com.czjtxy.extraTerm.serverImpl.NoticeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @author ZhangYing
 * @class 软件1903
 * @studentID 19852035
 * @date 2021/7/4
 */

@WebServlet(name = "NoticeServlet", value = "/NoticeServlet")
public class NoticeServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        NoticeService noticeService = new NoticeServiceImpl();
        List<TnoticeVO> tnoticeVOs = null;
        try {
            tnoticeVOs = noticeService.getAll();
            req.setAttribute("tnotices", tnoticeVOs);
        } catch (SQLException | ClassNotFoundException throwables) {
            throwables.printStackTrace();
        }
        req.getRequestDispatcher("notice/notice.jsp").forward(req, resp);
    }
}
